from django.shortcuts import render
#防止csrf 的cookie攻击
from django.views.decorators.csrf import csrf_exempt

# Create your views here.
from django.http import HttpResponse

from django.conf import settings
import os
#引用平级模块 from .文件名
from .blog import blog

from datetime import datetime

def index(request):
    return render(request, 'index.html')
#跳转新增页面
def to_add(request):
    #这个context参数是字典
    fuck = {'fuck':'你个龟儿子坏的很'}
    return render(request,'add.html',fuck)
# create
@csrf_exempt
def add(request):
    #字典形式进行获取
    title = request.POST['title']
    content = request.POST['content']
    create_time = datetime.now()
    tag = request.POST['tag'];
    obj = blog(title=title,content=content,create_time=create_time,tag=tag)
    obj.save()
    fuck = {'fuck': '存储成功！你个糟老头'}
    return render(request,'add.html',fuck)
